package com.ado.bazinga.core.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.ado.bazinga.core.dal.dao.ShopCartMapper;
import com.ado.bazinga.core.dal.entity.ShopCart;
import com.ado.bazinga.core.manager.ShopCartManager;
import com.ado.bazinga.core.service.ShopCartService;

/**
 *@author adonais
 *@date 2020年3月26日
 *@description ShopCartServiceImpl.java
**/
@Service(value = "shopCartService")
public class ShopCartServiceImpl implements ShopCartService{
	
	@Autowired
	@Qualifier(value = "shopCartManager")
	private ShopCartManager shopCartManager;
	@Autowired
	private ShopCartMapper shopCartMapper ;

	@Override
	public boolean createShopCart(ShopCart shopCart) {
		boolean flag = shopCartManager.save(shopCart);
		return flag;
	}

	@Override
	public List<ShopCart> getUserShopCarts(Integer userId) {
		List<ShopCart> shopCarts = shopCartMapper.getUserShopCarts(userId) ;
		return shopCarts;
	}

	@Override
	public boolean deleteShopCart(Integer shopCartId) {
		boolean flag = shopCartManager.removeById(shopCartId) ;
		return flag;
	}

	@Override
	public ShopCart getShopCartById(String shopCartId) {
		return shopCartManager.getById(Integer.valueOf(shopCartId));
	}

}
